package com.test.mytest.saolei.swing;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

public class ShowGifPanel extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private ImageIcon icon=null;
	@Override
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		if (icon!=null) {
			Rectangle bounds = getBounds();
			g.drawImage(icon.getImage(), 0, 0, bounds.width, bounds.height, this);
		}
	}
	public void setBackgroudImage(String fileName){
		icon=new ImageIcon(fileName);
		repaint();
	}
	public void setBackgroudImage(Image image){
		icon=new ImageIcon(image);
		repaint();
	}
}
